/**
 * Copyright © 2018
 * 
 */
package com.adds.lvds.service.impl.monit;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.adds.lvds.core.plugin.PageView;
import com.adds.lvds.core.utils.CommUtils;
import com.adds.lvds.dao.impl.monit.MonitTaskMapper;
import com.adds.lvds.model.monit.Monit_task_base;

/**
 * @author: zhangjian
 * @date: 2018年6月22日 下午2:20:31
 * @desc 监控任务业务层
 */
@Service("monitTaskService")
public class MonitTaskService {
	@Autowired
	private MonitTaskMapper monitTaskMapper;

	/**
	 * 创建监控任务基础数据
	 * 
	 * @param monit_task_base
	 * @throws Exception
	 */
	public String insertMonit_task_base(Monit_task_base monit_task_base) {
		String result = CommUtils.SUCC;
		try {
			monitTaskMapper.insertMonit_task_base(monit_task_base);
		} catch (Exception e) {
			result = CommUtils.ERROR;
			e.printStackTrace();
		}
		return result;
	}

	/**
	 * 编辑监控任务基础数据
	 * 
	 * @param monit_task_base
	 * @throws Exception
	 */
	public String editMonit_task_base(Monit_task_base monit_task_base) {
		String result = CommUtils.SUCC;
		try {
			monitTaskMapper.editMonit_task_base(monit_task_base);
		} catch (Exception e) {
			result = CommUtils.ERROR;
			e.printStackTrace();
		}
		return result;
	}

	/**
	 * 删除监控任务基础数据
	 * 
	 * @param map
	 * @throws Exception
	 */
	public String deleteMonit_task_base(String[] ids) {
		String result = CommUtils.SUCC;
		try {
			monitTaskMapper.deleteMonit_task_base(ids);
		} catch (Exception e) {
			result = CommUtils.ERROR;
			e.printStackTrace();
		}
		return result;
	}

	/**
	 * 根据条件获取基础数据
	 * 
	 * @param map
	 * @return
	 * @throws Exception
	 */
	public List<Monit_task_base> queryMonit_task_baseByMap(Map<String, Object> map) {
		List<Monit_task_base> list = null;
		try {
			list = monitTaskMapper.queryMonit_task_baseByMap(map);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return list;
	}

	/**
	 * 根据条件获取基础数据
	 * 
	 * @param map
	 * @return
	 * @throws Exception
	 */
	public Monit_task_base findMonit_task_baseByMap(Map<String, Object> map) {
		Monit_task_base monit_task_base = null;
		try {
			List<Monit_task_base> list = monitTaskMapper.queryMonit_task_baseByMap(map);
			if (!list.isEmpty()) {
				monit_task_base = list.get(0);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return monit_task_base;
	}

	/**
	 * 分页显示监控任务数据
	 * 
	 * @param map
	 * @return
	 * @throws Exception
	 */
	public PageView<Monit_task_base> pageMonit_task_baseByCondition(PageView<Monit_task_base> pageView,
			Monit_task_base t) {
		try {
			Map<String, Object> map = new HashMap<String, Object>();
			map.put("paging", pageView);
			map.put("t", t);
			List<Monit_task_base> list = monitTaskMapper.pageMonit_task_baseByCondition(map);
			pageView.setRecords(list);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return pageView;
	}
}
